﻿using KayakMes.Check.Application;
using KayakMes.Check.Application.Input;
using KayakMes.Check.Domain;
using KayakMes.Common.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;

namespace KayakMes.Check.API.Controllers
{
    /// <summary>
    /// 检测项目分类控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CheckItemController : ControllerBase
    {
        private readonly ICheckItemService _checkItemService;

        public CheckItemController(ICheckItemService checkItemService)
        {
            _checkItemService = checkItemService;
        }

        /// <summary>
        /// 添加检查项
        /// </summary>
        /// <param name="checkItem"></param>
        /// <returns></returns>
        /// 

        [HttpPost]
        public ApiResult<int> AddCheckItem(AddCheckItemInput checkItem)
        {
            return _checkItemService.AddCheckItem(checkItem);
        }
        /// <summary>
        /// 获取检查项目
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<CheckItemModel> CheckItemModel(long Id)
        {
           return _checkItemService.CheckItemModel(Id);
        }
        /// <summary>
        /// 删除检测项
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public ApiResult<int> DeleteCheckItem(long Id)
        {
          return _checkItemService.DeleteCheckItem(Id);

        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// 
        [HttpGet]
        public ApiPaging<CheckItemModel> GetAllCheckItem([FromQuery]CheckItemInput input)
        {

          return _checkItemService.GetAllCheckItem(input);


        }
        /// <summary>
        /// 随机生成检测项目编号
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public string GetCheckItemCode()
        {
           return _checkItemService.GetCheckItemCode();
        }
        /// <summary>
        /// 修改检测项目
        /// </summary>
        /// <param name="checkItem"></param>
        /// <returns></returns>
        /// 
        [HttpPut]
        public ApiResult<int> UpdateCheckItem(UpdateChenitemInput checkItem)
        {
           return _checkItemService.UpdateCheckItem(checkItem);
        }
       

    }
}
